home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-26 | 6.7 KB | 226 lines | [TEXT/ttxt] |
- \ list manager routines - window used for maintaining a scrollable list
- \ 6/29/92 rfl fixed bug by allowing IMOD to be seen in scroll pane
- \ 5/23/93 rfl removed new: modlist...don't want this to happen during module compile
- \ also don't include imod itself.
- \ 6.26.93 rfl fixed bug when clicking at edge of scrollbar..14 to 15 in setrect:
-
- \ NEED TO PROTECT FOR 32K LIMIT
-
- : within { x lo hi -- b }
- x hi >= x lo <= and ;
-
- \ generic class of windows that includes a pane of scrolling text
- :CLASS TscrollWind <super ctlwind
-
- handle lhandle \ handle to list
- rect rview \ scrollable area
- rect pane \ rview plus scroll bar
- \ rect databounds \ always 1 column
- int theFont
- int fontSize
- int usage \ how to respond to shift, command, etc.
- int AutoScroll \ if true, then when new item is printed, scroll to it immediately
- point theCell \ to determine if a cell is selected...col,row
-
- \ **********************
- \ INIT METHODS
-
- :M setRect: put: rview get: rview swap 15 + swap put: pane
- -1 -1 inset: pane ;M
-
- :M setListFont: put: fontSize put: theFont ;M
- :M setUsage: put: usage ;M
- :M restoreFont: get: theFont tfont get: fontSize tsize ;M
- :M autoScroll: ( n --) put: autoscroll ;M
-
- \ **********************
-
- \ sets selflags
- :M usage: get: usage get: lhandle -dup IF >ptr 36 + c! THEN ;M
-
- :M newList: get: theFont tfont get: fontSize tsize
- 0 abs: rview 0 0 1 0 put: tempRect abs: tempRect
- size: rview drop 0 pack
- word0 abs: self
- true bool \ drawit
- get: growFlg bool \ growbox?
- false bool true bool \ no horizontal scroll, yes vert scroll
- call lnew put: lhandle usage: self ;M
-
- :M new: alive: self not IF new: super newList: self ELSE select: self THEN -curs ;M
-
- :M getnew: alive: self not IF getnew: super newList: self ELSE select: self THEN -curs ;M
-
- :M closeList: get: lhandle call ldispose clear: lhandle ;M
-
- :M close: alive: self IF closeList: self close: super THEN ;M
-
- :M draw: pushPort set: self restoreFont: self
- ^base 24 + @ get: lhandle call lupdate draw: pane popPort
- draw: super ;M
-
- \ :M addCols: { count -- }
- \ w0 count makeint 0 makeint get: lhandle call laddcolumn i->l drop ;M
-
- :M NRows: ( -- n) ptr: lhandle 84 + w@ 2/ ;M
-
- :M addRows: { count row# -- }
- word0 count makeint row# makeint get: lhandle call lAddRow i->l drop ;M
-
- ( -- x )
- :M SelectedCell: 0 get: lhandle call LLastClick unpack swap drop ;M
-
- ( tf -- )
- :M drawing: { drawIt -- } get: lhandle
- IF drawIt bool get: lhandle call LDoDraw THEN ;M
-
- \ replaces text and cell index
- :M putText: { addr len index -- }
- addr +base len makeint 0 index pack get: lhandle call lSetCell ;M
-
- \ concatenates text to current row
- :M addText: { addr len -- } alive: self
- IF addr +base len 255 min
- makeint 0 Nrows: self 1- pack get: lhandle call laddtocell
- THEN ;M
-
- ( -- addr len ) \ get text that was selected
- :M getText: pad +base dup 2+ swap 0 selectedCell: self pack
- get: lhandle call LgetCell pad 1+ count ;M
-
- \ positions list so that selected cell is visible
- :M position: get: autoScroll IF get: lhandle call lAutoScroll THEN ;M
-
- \ selects the nth item in the list if flag=true;deselect if flag=false
- :M selectCell: { flag index -- } flag bool 0 index pack get: lhandle
- call lSetSelect position: self ;M
-
- :M hilite: { index -- } 1 index selectCell: self ;M
- :M nohilite: { index -- } 0 index selectCell: self ;M
-
- \ puts text to new row at end of list, hilites it, and scrolls down
- :M newText: { addr len \ #rows -- }
- Nrows: self -> #rows
- 1 #rows addRows: self addr len #rows putText: self
- #rows hilite: self position: self #rows nohilite: self ;M
-
- :M IsCellSelected: ( ind --) 0 swap put: theCell
- 0 makeint true makeint abs: theCell get: lhandle call lGetSelect i->l ;M
-
- :M lHandle: get: lhandle ;M
-
- :M classinit: classinit: super 'c null put: draw true put: autoScroll ;M
-
- ;CLASS
-
- control SelectBut \ the ok button
- control NoneBut
- control AllBut
- control defaultBut
-
- :CLASS listWind <super TscrollWind
-
- var dblAct \ what to do on dblClick
- var act1 \ what to do if a cell is selected
-
- \ **********************
- \ INIT METHODS
-
- :M dblAction: put: dblAct ;M
- :M putMyAct: put: act1 ;M
- \ **********************
-
- ( --tf)
- :M ptInArea: where: themouse pack Ptin: pane ;M
-
- :M CONTENT: active: self
- IF ptInArea: self
- IF word0 where: fevent g->l mods: fevent makeint
- get: lhandle call lclick i->l \ if true, dblclick
- selectedCell: self 0< not
- IF exec: act1 THEN \ enable buttons if cell selected
- IF exec: dblAct THEN
- ELSE ^base ctlHit? not
- IF exec: content THEN
- THEN
- ELSE (abs) call SelectWindow
- THEN ;M
-
- \ if it's a cr then accept the selections and exit
- :M key: $ 000000ff and 13 = IF 1 exec: SelectBut ELSE errbeep THEN ;M
-
- :M classinit: classinit: super 'c null dup put: dblAct put: act1 ;M
-
- ;CLASS
-
-
- listWind Modwind
- 10 30 110 162 setrect: Modwind
- 3 9 setListFont: Modwind
- 68 setusage: Modwind \ allow multiple clicks without a modifier key
- -10000 dup 10000 dup true setdrag: Modwind
-
- sarray modList
-
- : (.mod) { theCfa size -- } curs -curs theCfa ?mod
- IF theCfa >name n>count
- 2dup " IMOD" s= not IF add: modList ELSE 2drop THEN
- THEN -> curs ;
-
- \ list modules and their load status
- : .mods 'c (.mod) 0 trav ;
-
-
- \ fills the list using names in ModList
- : fillCol
- false drawing: Modwind limit: modList 0
- DO i at: modList i putText: Modwind
- LOOP true drawing: Modwind ;
-
- : prepList limit: ModList 0 addrows: Modwind fillCol ;
-
- : buildModWind new: modList .mods 200 200 430 385 put: temprect
- temprect " Modules" docWind false false new: ModWind
- 140 80 " Ok" modWind new: selectBut
- 140 110 " All" modWind new: AllBut
- 140 140 " None" modWind new: NoneBut
- 140 50 " Default" modWind new: defaultBut
- -curs 1000 1000 gotoxy
- size: modList
- IF prepList THEN show: modwind ;
-
- : ModTitle -curs 0 tfont 12 tsize 10 19 gotoxy ." Select all mods to include…"
- restoreFont: modWind ;
-
- 4 'cfas null null modTitle errbeep actions: modwind
- 2 'cfas null null setact: modwind
-
- 20 ordered-col nmods
-
- : acceptSelect clear: nmods
- nrows: modWind 0 DO i isCellSelected: modWind
- IF i at: modList sfind 2drop cfa add: nmods THEN loop
- close: modWind release: modList ;
-
- : selectAll nrows: modWind 0 DO true i selectCell: modWind LOOP ;
- : selectNone nrows: modWind 0 DO false nrows: modWind i- 1- selectCell: modWind LOOP ;
-
- 'c acceptSelect actions: selectbut
- 'c selectAll actions: allBut
- 'c selectNone actions: noneBut
-
- 6 ordered-col defaultMods
- 'c AlertMod add: defaultMods
- 'c indMod add: defaultMods
- 'c PrintMod add: defaultMods
- 'c sortMod add: defaultMods
- 'c aboutMod add: defaultMods
- 'c env add: defaultMods
-
- : selectDefaults limit: modList 0
- DO i at: modList sfind 2drop cfa indexof: defaultMods
- IF drop true i selectCell: modWind THEN
- LOOP ;
-
- 'c SelectDefaults actions: defaultBut
-